#include<stdio.h>
#include<stdbool.h>
bool is_leap_year(int y)
{
    if(((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0))
        return true;
    else
        return false;


}
int get_days_of_month(int y,int m)
{
    int days[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    int day = days[m];
    if(is_leap_year(y) && m == 2)
    {
        day++;
    }
    return day;
}
int main()
{
    int year , month;
    scanf("%d %d",&year,&month);
    int day = get_days_of_month(year,month);
    printf("%d",day);
    return 0;
}